<template>
  <div ref="charts01" class="bar"></div>
</template>

<script>
import * as echarts from "echarts";
export default {
  mounted() {
    // 指定图表的配置项和数据
    var myChart = echarts.init(this.$refs.charts01);
    var option = {
      title: {
        text: "",
      },
      tooltip: {},
      legend: {},
      //设置布局
      grid: {
        left: 0,
        right: 0,
        top: 0,
        bottom: 0,
      },
      xAxis: {
        type: "category",
          show:false
        // data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
      },
      yAxis: {
          show:false
      },
      series: [
        {
          type: "bar",
          data: [30, 20, 36, 10, 10, 20],
          label: {
            show: true,
          },
        },
      ],

      tooltip: {
        confine: true,
        position: function (point, params, dom, rect, size) {
          // 固定在顶部
          return [point[0], "10%"];
        },
      },
    };
    myChart.setOption(option);
    window.addEventListener("resize", () => {
      //图标自适应
      myChart.resize();
    });
  },
};
</script>

<style lang="scss" scoped>
.bar {
  width: 100%;
  height: 100%;
}
</style>